// wThermal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include "CSensorEvents.h"
#include "CSensorManagerEvents.h"
#include <Sensorsapi.h>
#include <sensors.h>
#include <SensAPI.h>
#include <initguid.h>
#include <propkeydef.h>
#include <comutil.h>
#include <math.h>

#pragma comment(lib, "Sensorsapi.lib")

CSensorManagerEvents* m_pSensorManagerEvents;


int getSensors(int sType)
{
	m_pSensorManagerEvents = new CSensorManagerEvents();

	m_pSensorManagerEvents->m_pSensorEvents->SetStandard(sType);

	if (SUCCEEDED(m_pSensorManagerEvents->Initialize()))
		return 0;
	else
		return 1;
}

void usage()
{
	fprintf(stderr, "usage:\n  wThermal.exe [/c value]|[/s value]");
	fprintf(stderr, "\n\nOption:\n  /c value:   TEMPERATURE standard need to check...");
	fprintf(stderr, "\n  /s value:   TEMPERATURE rise steps need to check...");

	fprintf(stderr, "\n\nReturn code:\n  0: Pass, 1 Fail");
	exit(1);
}

int main(int argc, char* argv[])
{
	MSG msg; 
	int std=100;

	if (argc==2 && strcmp(argv[1], "/?")==0)
		usage();

	if (argc==3 && strcmp(argv[1], "/c")==0)
		std = atoi(argv[2]);

	if (argc==3 && strcmp(argv[1], "/s")==0)
		std = atoi(argv[2])*1000;

	if(std==0) 
		usage();

	CoInitialize(0); 
  
	getSensors(std);

	while (GetMessage(&msg, NULL, 0, 0))
	{ 
		if (!TranslateAccelerator(msg.hwnd, NULL, &msg))  
		{  
			TranslateMessage(&msg);  
			DispatchMessage(&msg);  
		} 
	}
	CoUninitialize();
	return 0;
}